﻿using Foundation.Core;

namespace Dyao.Book.Web.Extensions
{
    public class ServiceMethodSelectCollectionUniOfWrokCreatorFactory : ISelectCollectionCreatorFactory, ITransientDependency
    {
        private readonly IServiceProvider _serviceProvider;

        public ServiceMethodSelectCollectionUniOfWrokCreatorFactory(IServiceProvider serviceProvider)
        {
            this._serviceProvider = serviceProvider;
        }

        public ISelectCollectionCreator Create(SelectItemOptions options)
        {
            var methodOptions = options.MethodOptions;
            if (methodOptions != null)
            {
                return new ServiceMethodSelectCollectionUniOfWrokCreator(methodOptions, _serviceProvider);
            }

            throw new AppException($"{options.Key},{options.Category},未配置获取选项的方法信息。");
        }
    }
}
